local anjie = fk.CreateSkill{
  name = "plum__anjie",
  tags = {Skill.Compulsory}
}

Fk:loadTranslationTable{
  ["plum__anjie"] = "暗解",
  [":plum__anjie"] = "锁定技，当你使用一张牌后，你重铸转化底牌数张牌，然后不能再以此法重铸此数量张牌，直到你失去所有牌。",

  ["#plum__anjie-recast"] = "暗解：请重铸%arg张牌",

  ["$plum__anjie1"] = "天垂异，地吐妖，人君之德不明也。",
  ["$plum__anjie2"] = "浊而返清，阴欲为阳，此诸侯欲王也。",
}

anjie:addEffect(fk.CardUseFinished, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) then
      local n = #Card:getIdList(data.card)
      return n > 0 and #player:getCardIds("he") >= n and not table.contains(player:getTableMark(anjie.name), n)
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = #Card:getIdList(data.card)
    local cards = room:askToCards(player, {
      max_num = n,
      min_num = n,
      include_equip = true,
      skill_name = anjie.name,
      cancelable = false,
      prompt = "#plum__anjie-recast:::"..n
    })
    room:recastCard(cards, player, anjie.name)
    if not player.dead then
      room:addTableMark(player, anjie.name, n)
    end
  end,
})

anjie:addEffect(fk.AfterCardsMove, {
  can_refresh = function(self, event, target, player, data)
    if player:getMark(anjie.name) == 0 or not player:isNude() then return end
    for _, move in ipairs(data) do
      if move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea <= Card.PlayerEquip then
            return true
          end
        end
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, anjie.name, 0)
  end,
})

return anjie